package com.zh.remote.imp;

import com.zh.mapstruct.DriverStructMapper;
import com.zh.pojo.domain.DriverSummary;
import com.zh.remote.api.DriverApi;
import com.zh.remote.pojo.param.DriverSummaryResult;
import com.zh.result.JSONResult;
import com.zh.service.IDriverSummaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * 远程调用drover对象 ，并实现DriverApi接口
 */
@RestController
public class RemoteDriverApiImpl implements DriverApi {
    @Autowired
    private IDriverSummaryService summaryService;


    /**
     * 查询司机汇总数据
     * @param driverId
     * @return
     */
    @Override
    public JSONResult<DriverSummaryResult> getDriverSummary(Long driverId) {
        DriverSummary summary = summaryService.getById(driverId);
        DriverSummaryResult driverSummaryResult = DriverStructMapper.INSTANCE.driverSummaryConvertToDriverSummaryResult(summary);
        return JSONResult.success(driverSummaryResult);
    }
}
